﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace DataModel
{
    public class ErrorMessage:IEquatable<ErrorMessage>
    {
        public ErrorMessage(string PropertyName, string Message, params object[] Parameters)
        {
            this.propertyName = PropertyName;
            this.Message = Message;
            this.Parameters = Parameters;
        }
        public string propertyName {get; private set;}
        string Message { get; set; }
        object[] Parameters { get; set; }

        public string GetMessage { get { return string.Format(Message, Parameters); } }

        public override string ToString()
        {
            return GetMessage;
        }

        #region IEquatable<ErrorMessage> Members
        public override int GetHashCode()
        {
            return (propertyName + Message).GetHashCode();
        }
        public override bool Equals(object obj)
        {
            if (obj is ErrorMessage)
            {
                return Equals((ErrorMessage)obj);
            }
            return false;
        }

        public bool Equals(ErrorMessage other)
        {
            if (other == null)
            {
                return false;
            }
            else
            {
                return propertyName.Equals(other.propertyName) && Message.Equals(other.Message);
            }
        }

        #endregion
    }
}
